#include "minimap.hpp"

cMiniMap::cMiniMap(int ww, int hh, int xx, int yy, cMap * map)
{
    isDrawing = false;
    w = ww; h = hh;
    img = create_bitmap(w+2, h+2);
    x = xx;
    y = yy;

    for (int j = 0; j < h; j++)
    {
        for (int i = 0; i < w; i++)
        {
            if (map->map_green[i][j] != -1) _putpixel32(img, i, j, 0);
            else stretch_blit(map->tex, img, map->map[i][j] * TILE_SIZE, 0, TILE_SIZE, TILE_SIZE, i, j, 1, 1);
        }
    }
}

void cMiniMap::draw(BITMAP * bufor, int hX, int hY, int mW, int mH)
{
    stretch_blit(img, bufor, 0, 0, w, h, x + 1, y + 1, 100, 100);

    hline(bufor, x, y, x + 100, 0);
    hline(bufor, x, 100, x + 100, 0);
    vline(bufor, x, 0, 100, 0);
    vline(bufor, x + 100, 0, 100, 0);

    _putpixel32(bufor, x + hX * 100 / mW, y + hY * 100 / mH, 0xFF0000);
}
